﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using JobbJakt;

namespace JobbJaktWeb
{
    public partial class DeleteUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ButtonRemoveUser_Click(object sender, EventArgs e)
        {
            try
            {
                var user = Users.PrintUser(TextBoxSpecifyUserName.Text.Trim());

                if (user != null)
                {
                    Users.RemoveUser(user.UserName);
                    LabelUserInActivated.Enabled = true;
                }
                else
                {
                    LabelUserNonExisting.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                ErrorTable newErrorTable = new ErrorTable() { Message = ex.Message, Type = ex.GetType().ToString() };
                ErrorTable.InsertError(newErrorTable);
                throw new Exception();
            }

        }
    }
}